#ifndef ResponseItem_H
#define ResponseItem_H

#include "ModelItems/TreeItem.h"
#include "..\..\core\src\AssetManager.h"
#include "..\..\core\src\container\ResponseAttribute.h"

namespace Xps
{
	class ResponseItem : public TreeItem
	{
	public:
		ResponseItem(XpsAssets::AssetManager* am, int id, int pid = -1) : TreeItem(am,id,ModelItemType::RESPONSE, pid)
		{
			asset = am->getResponse(id);
			setIcon(QIcon(":/rs/images/response.png"));
		};

		
		QVariant ResponseItem::data (int role) const
		{
			XpsAssets::Response* r;
			r = (XpsAssets::Response*) asset;
			
			if (role == Qt::EditRole || role == Qt::DisplayRole)
			{
				return QString("%1 %2").arg(r->id(),3,10,QChar('0')).arg(r->text());
			}
				
			return TreeItem::data(role);
		}

		void ResponseItem::setData ( const QVariant & value, int role)
		{
			if (role != Qt::EditRole) 
				return TreeItem::setData(value,role);

			XpsAssets::Response* r = (XpsAssets::Response*) asset;
			r->setText(value.toString());
		}
	};
}
#endif